import 'package:flutter/material.dart';
import 'home_cell.dart';
import 'add_remind_vc.dart';

class HomeVC extends StatefulWidget {
  @override
  HomeVCState createState() => new HomeVCState();
}

class HomeVCState extends State<HomeVC> {

  var list = [
    {"text": "1111", "color": Colors.red},
    {"text": "2222", "color": Colors.purple},
    {"text": "1133333242342342342343242342343242342342343242311", "color": Colors.cyan},
    {"text": "113333324234234234234324234234324234234234324231112311231312312312312313", "color": Colors.red},
    {"text": "1231313", "color": Colors.blue},
    {"text": "1112312311", "color": Colors.red},
    {"text": "12312312312", "color": Colors.blue},
    {"text": "1fadsdadasdasdasd111", "color": Colors.yellow},
    {"text": "111231dsfasfa11", "color": Colors.green},
  ];

  @override
  Widget build(BuildContext context) {

    return new Scaffold(
      resizeToAvoidBottomPadding: false,
      appBar: new AppBar(
        title: new Text('HomeVC'),
      ),
      body: Container(
//        color: Colors.green,
//        margin: EdgeInsets.all(20),
          child: ListView.builder(
              itemCount: list.length,
              itemBuilder: (context, index) {
                final content = list[index];
                final text = content["text"];
                final color = content["color"];
                return HomeCell(index, text, color);
//                HomeCell();
//                Padding(
//                padding: EdgeInsets.all(20),
//                child: Container(
//                  color: Colors.blue[100],
//                  child: HomeCell(index),
//                )
//              );
              })),
      floatingActionButton: FloatingActionButton(
//        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
        onPressed: () {
          Navigator.push(context, MaterialPageRoute(builder: (context) => AddRemindVC())).then((value) {
            print(value);
            if(value != null) {
              this.list.insert(0, value);
              setState(() {

              });
            }
          });
        },
      ), // T
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  @override
  void didUpdateWidget(HomeVC oldWidget) {
    // TODO: implement didUpdateWidget
    super.didUpdateWidget(oldWidget);
  }

  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
  }
}
